package com.guigu.qingcheng.service_user.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.guigu.qingcheng.pojo.user.UserOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface UserOrderMapper extends BaseMapper<UserOrder> {

    @Select("SELECT  u.*,c.usercount usercount,c.num num FROM \n" +
            "(SELECT a.username uname,COUNT(a.username) usercount ,SUM(a.pay_money) num\n" +
            "FROM qingcheng_order.`tb_order` a,qingcheng_user.`tb_user` b WHERE a.username=b.username GROUP BY b.username) c \n" +
            "RIGHT JOIN qingcheng_user.tb_user u\n" +
            "ON c.uname = u.username\n" +
            "GROUP BY u.username")
    public List<UserOrder> selectUserOrder(QueryWrapper<UserOrder> queryWrapper);


}
